package com.jpxx.netty.runtime;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;

public class ClientHandler extends ChannelHandlerAdapter{  


	@Override  
	public void channelActive(ChannelHandlerContext ctx) {  
		System.out.println("Cllent  go````客户端开启");  
	}  

	@Override  
	public void channelRead(ChannelHandlerContext ctx, Object msg) {  
		 Response response = (Response) msg;  
         System.out.println("server反馈(response)："+response);  
		 //ctx.writeAndFlush("你好Netty服务器 ,我是一个常见的客户端333").addListener(ChannelFutureListener.CLOSE); //关闭连接
	}
	
	


	@Override
	public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
		//System.out.println("客户端--读取完毕----channelReadComplete");  
	}

	@Override  
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {  
		//System.out.println("client_exceptionCaught__异常");  
		cause.printStackTrace();  
		ctx.close();//关闭连接 
	}  

}  